<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>example</title><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

<link rel="stylesheet" href="./static/style.min.css" />
<link rel="stylesheet" href="./static/highlight.min.css" />
<link rel="stylesheet" href="./static/temporary.min.css" />
<!-- Custom stylesheet, it must be in the same directory as the html file -->
<link rel="stylesheet" href="./static/custom.css">

<style type="text/css">
/* Overrides of notebook CSS for static HTML export */
body {
  overflow: visible;
  padding: 8px;
}

div#notebook {
  overflow: visible;
  border-top: none;
}@media print {
  div.cell {
    display: block;
    page-break-inside: avoid;
  } 
  div.output_wrapper { 
    display: block;
    page-break-inside: avoid; 
  }
  div.output { 
    display: block;
    page-break-inside: avoid; 
  }
}
</style></head>
<body>
  <div tabindex="-1" id="notebook" class="border-box-sizing">
    <div class="container" id="notebook-container">

<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="&#31616;&#21333;&#30340;&#20363;&#23376;">&#31616;&#21333;&#30340;&#20363;&#23376;<a class="anchor-link" href="#&#31616;&#21333;&#30340;&#20363;&#23376;">&#182;</a></h1>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p><span style="float: left">Prev: <a href="./index.html">乘车指南 🚇</a></span>
<span style="float: right">Next: <a href="./objects.html">Jike Metro 🚇 中各个类的可用属性</a></span></p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[1]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">import</span> <span class="nn">jike</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">jike</span><span class="o">.</span><span class="n">JikeClient</span><span class="p">()</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="&#33719;&#21462;&#29926;&#24635;&#21644;&#19981;&#31649;&#22992;&#31881;&#19997;&#24615;&#21035;&#30334;&#20998;&#27604;">&#33719;&#21462;&#29926;&#24635;&#21644;&#19981;&#31649;&#22992;&#31881;&#19997;&#24615;&#21035;&#30334;&#20998;&#27604;<a class="anchor-link" href="#&#33719;&#21462;&#29926;&#24635;&#21644;&#19981;&#31649;&#22992;&#31881;&#19997;&#24615;&#21035;&#30334;&#20998;&#27604;">&#182;</a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>想法来自 <a href="https://web.okjike.com/user/c7d257c7-a4fc-4383-a779-49f3123adfab/post">劳斯判据</a> 的 <a href="https://web.okjike.com/post-detail/5ac0a1dee72e500017c5e47f/originalPost">动态</a></p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[2]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># 瓦总</span>
<span class="n">ceo_follower</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get_user_follower</span><span class="p">(</span><span class="n">username</span><span class="o">=</span><span class="s1">&#39;82D23B32-CF36-4C59-AD6F-D05E3552CBF3&#39;</span><span class="p">)</span>
<span class="n">ceo_follower</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[2]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>List(20 items)</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[3]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">ceo_follower</span><span class="o">.</span><span class="n">load_all</span><span class="p">()</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[3]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>19956</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[4]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># 不管姐</span>
<span class="n">boss_follower</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get_user_follower</span><span class="p">(</span><span class="n">username</span><span class="o">=</span><span class="s1">&#39;B5C00109-15EA-4351-8B93-E58651E8C39D&#39;</span><span class="p">)</span>
<span class="n">boss_follower</span><span class="o">.</span><span class="n">load_all</span><span class="p">()</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[4]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>4388</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[5]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">ceo_male_fan_count</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">((</span><span class="n">follower</span><span class="o">.</span><span class="n">gender</span> <span class="o">==</span> <span class="s1">&#39;MALE&#39;</span> <span class="k">for</span> <span class="n">follower</span> <span class="ow">in</span> <span class="n">ceo_follower</span><span class="p">))</span>
<span class="n">ceo_female_fan_count</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">((</span><span class="n">follower</span><span class="o">.</span><span class="n">gender</span> <span class="o">==</span> <span class="s1">&#39;FEMALE&#39;</span> <span class="k">for</span> <span class="n">follower</span> <span class="ow">in</span> <span class="n">ceo_follower</span><span class="p">))</span>
<span class="n">ceo_other_fan_count</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="n">follower</span><span class="o">.</span><span class="n">gender</span> <span class="o">==</span> <span class="kc">None</span> <span class="k">for</span> <span class="n">follower</span> <span class="ow">in</span> <span class="n">ceo_follower</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">ceo_male_fan_count</span><span class="p">,</span> <span class="n">ceo_female_fan_count</span><span class="p">,</span> <span class="n">ceo_other_fan_count</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>


<div class="output_subarea output_stream output_stdout output_text">
<pre>12794 4070 3092
</pre>
</div>
</div>

</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[6]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">boss_male_fan_count</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">((</span><span class="n">follower</span><span class="o">.</span><span class="n">gender</span> <span class="o">==</span> <span class="s1">&#39;MALE&#39;</span> <span class="k">for</span> <span class="n">follower</span> <span class="ow">in</span> <span class="n">boss_follower</span><span class="p">))</span>
<span class="n">boss_female_fan_count</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">((</span><span class="n">follower</span><span class="o">.</span><span class="n">gender</span> <span class="o">==</span> <span class="s1">&#39;FEMALE&#39;</span> <span class="k">for</span> <span class="n">follower</span> <span class="ow">in</span> <span class="n">boss_follower</span><span class="p">))</span>
<span class="n">boss_other_fan_count</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="n">follower</span><span class="o">.</span><span class="n">gender</span> <span class="o">==</span> <span class="kc">None</span> <span class="k">for</span> <span class="n">follower</span> <span class="ow">in</span> <span class="n">boss_follower</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">boss_male_fan_count</span><span class="p">,</span> <span class="n">boss_female_fan_count</span><span class="p">,</span> <span class="n">boss_other_fan_count</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>


<div class="output_subarea output_stream output_stdout output_text">
<pre>2844 1163 381
</pre>
</div>
</div>

</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[7]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="o">%</span><span class="k">matplotlib</span> inline
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
<span class="kn">from</span> <span class="nn">matplotlib.gridspec</span> <span class="k">import</span> <span class="n">GridSpec</span>

<span class="n">labels</span> <span class="o">=</span> <span class="s1">&#39;male&#39;</span><span class="p">,</span> <span class="s1">&#39;female&#39;</span><span class="p">,</span> <span class="s1">&#39;unknown&#39;</span>
<span class="n">ceo_stats</span> <span class="o">=</span> <span class="p">(</span><span class="n">ceo_male_fan_count</span><span class="p">,</span> <span class="n">ceo_female_fan_count</span><span class="p">,</span> <span class="n">ceo_other_fan_count</span><span class="p">)</span>
<span class="n">boss_stats</span> <span class="o">=</span> <span class="p">(</span><span class="n">boss_male_fan_count</span><span class="p">,</span> <span class="n">boss_female_fan_count</span><span class="p">,</span> <span class="n">boss_other_fan_count</span><span class="p">)</span>

<span class="n">the_grid</span> <span class="o">=</span> <span class="n">GridSpec</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">the_grid</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">aspect</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s1">&#39;ceo&#39;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">pie</span><span class="p">(</span><span class="n">ceo_stats</span><span class="p">,</span> <span class="n">labels</span><span class="o">=</span><span class="n">labels</span><span class="p">,</span> <span class="n">autopct</span><span class="o">=</span><span class="s1">&#39;</span><span class="si">%1.1f%%</span><span class="s1">&#39;</span><span class="p">,</span> <span class="n">shadow</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">the_grid</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">aspect</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s1">&#39;boss&#39;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">pie</span><span class="p">(</span><span class="n">boss_stats</span><span class="p">,</span> <span class="n">labels</span><span class="o">=</span><span class="n">labels</span><span class="p">,</span> <span class="n">autopct</span><span class="o">=</span><span class="s1">&#39;</span><span class="si">%1.1f%%</span><span class="s1">&#39;</span><span class="p">,</span> <span class="n">shadow</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>




<div class="output_png output_subarea ">
<img src="
"
>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="&#24215;&#38271;&#21457;&#36710;&#30340;&#26102;&#38388;&#20998;&#24067;">&#24215;&#38271;&#21457;&#36710;&#30340;&#26102;&#38388;&#20998;&#24067;<a class="anchor-link" href="#&#24215;&#38271;&#21457;&#36710;&#30340;&#26102;&#38388;&#20998;&#24067;">&#182;</a></h2><p>基于最近一个月 <a href="https://web.okjike.com/topic/5701d10d5002b912000e588d/official">不好笑便利店</a> 主题下的精选，由评论判断是否开车</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[8]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># 不好笑便利店 的主题精选</span>
<span class="n">selected</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get_topic_selected</span><span class="p">(</span><span class="n">topic_id</span><span class="o">=</span><span class="s1">&#39;5701d10d5002b912000e588d&#39;</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[9]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">datetime</span> <span class="k">import</span> <span class="n">datetime</span><span class="p">,</span> <span class="n">timedelta</span>
<span class="n">today</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">today</span><span class="p">()</span>
<span class="n">a_month_ago</span> <span class="o">=</span> <span class="n">today</span> <span class="o">-</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
<span class="n">date_parse</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">t</span><span class="p">:</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">t</span><span class="p">[:</span><span class="o">-</span><span class="mi">5</span><span class="p">],</span> <span class="s1">&#39;%Y-%m-</span><span class="si">%d</span><span class="s1">T%H:%M:%S&#39;</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[10]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">comment_keywords</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;奶&#39;</span><span class="p">,</span> <span class="s1">&#39;任务&#39;</span><span class="p">,</span> <span class="s1">&#39;爱尔兰&#39;</span><span class="p">,</span> <span class="s1">&#39;不动产&#39;</span><span class="p">,</span> <span class="s1">&#39;发车&#39;</span><span class="p">,</span> <span class="s1">&#39;开车&#39;</span><span class="p">,</span> <span class="s1">&#39;上车&#39;</span><span class="p">,</span> <span class="s1">&#39;窑子&#39;</span><span class="p">,</span> <span class="s1">&#39;黄色&#39;</span><span class="p">,</span> <span class="s1">&#39;黄即&#39;</span><span class="p">,</span> 
                    <span class="s1">&#39;片子&#39;</span><span class="p">,</span> <span class="s1">&#39;看片&#39;</span><span class="p">,</span> <span class="s1">&#39;借一部&#39;</span><span class="p">,</span> <span class="s1">&#39;资源&#39;</span><span class="p">,</span> <span class="s1">&#39;举报&#39;</span><span class="p">}</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[11]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="n">defaultdict</span>
<span class="n">time_periods</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">int</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[12]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">message_date</span> <span class="o">=</span> <span class="n">today</span>
<span class="k">while</span> <span class="n">message_date</span> <span class="o">&gt;</span> <span class="n">a_month_ago</span><span class="p">:</span>
    <span class="n">messages</span> <span class="o">=</span> <span class="n">selected</span><span class="o">.</span><span class="n">load_more</span><span class="p">(</span><span class="n">limit</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">message</span> <span class="ow">in</span> <span class="n">messages</span><span class="p">:</span>
        <span class="n">message_date</span> <span class="o">=</span> <span class="n">date_parse</span><span class="p">(</span><span class="n">message</span><span class="o">.</span><span class="n">createdAt</span><span class="p">)</span>
        <span class="n">comments</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get_comment</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
        <span class="n">comments</span><span class="o">.</span><span class="n">load_full</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">any</span><span class="p">((</span><span class="n">keyword</span> <span class="ow">in</span> <span class="n">comment</span><span class="o">.</span><span class="n">content</span> <span class="k">for</span> <span class="n">keyword</span> <span class="ow">in</span> <span class="n">comment_keywords</span><span class="p">)):</span>
                <span class="n">time_periods</span><span class="p">[</span><span class="n">message_date</span><span class="o">.</span><span class="n">hour</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[13]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># UTC time, should +8 for Asia/Shanghai</span>
<span class="n">adjusted_time_periods</span> <span class="o">=</span> <span class="p">[((</span><span class="n">h</span><span class="o">+</span><span class="mi">8</span><span class="p">)</span><span class="o">%</span><span class="k">24</span>, time_periods[h]) for h in range(24)]
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[14]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">adjusted_time_periods</span> <span class="o">=</span> <span class="n">adjusted_time_periods</span><span class="p">[</span><span class="o">-</span><span class="mi">8</span><span class="p">:]</span> <span class="o">+</span> <span class="n">adjusted_time_periods</span><span class="p">[:</span><span class="o">-</span><span class="mi">8</span><span class="p">]</span>
<span class="n">adjusted_time_periods</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[14]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>[(0, 0),
 (1, 0),
 (2, 0),
 (3, 0),
 (4, 0),
 (5, 0),
 (6, 0),
 (7, 0),
 (8, 13),
 (9, 20),
 (10, 8),
 (11, 20),
 (12, 33),
 (13, 30),
 (14, 42),
 (15, 71),
 (16, 17),
 (17, 37),
 (18, 41),
 (19, 31),
 (20, 41),
 (21, 38),
 (22, 18),
 (23, 2)]</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>店长最可能发车的三个时间段</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[15]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">total_cnt</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">((</span><span class="n">cnt</span> <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">cnt</span> <span class="ow">in</span> <span class="n">adjusted_time_periods</span><span class="p">))</span>

<span class="n">drive_time</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">adjusted_time_periods</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">t</span><span class="p">:</span> <span class="n">t</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">reverse</span><span class="o">=</span><span class="kc">True</span><span class="p">)[:</span><span class="mi">3</span><span class="p">]</span>
<span class="k">for</span> <span class="n">period</span><span class="p">,</span> <span class="n">cnt</span> <span class="ow">in</span> <span class="n">drive_time</span><span class="p">:</span>
    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;发车时间: </span><span class="si">{}</span><span class="s1">点，发车概率: </span><span class="si">{:.2%}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">period</span><span class="p">,</span> <span class="n">cnt</span> <span class="o">/</span> <span class="n">total_cnt</span><span class="p">))</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>


<div class="output_subarea output_stream output_stdout output_text">
<pre>发车时间: 15点，发车概率: 15.37%
发车时间: 14点，发车概率: 9.09%
发车时间: 18点，发车概率: 8.87%
</pre>
</div>
</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>店长发车的时间分布</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[16]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="o">%</span><span class="k">matplotlib</span> inline
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>

<span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">h</span><span class="p">,</span> <span class="n">cnt</span> <span class="ow">in</span> <span class="n">adjusted_time_periods</span><span class="p">:</span>
    <span class="n">data</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="n">h</span><span class="p">]</span><span class="o">*</span><span class="n">cnt</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">hist</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="nb">max</span><span class="p">(</span><span class="n">data</span><span class="p">)</span><span class="o">-</span><span class="nb">min</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">facecolor</span><span class="o">=</span><span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="n">align</span><span class="o">=</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="n">histtype</span><span class="o">=</span><span class="s1">&#39;bar&#39;</span><span class="p">,</span> <span class="n">rwidth</span><span class="o">=</span><span class="mf">0.9</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Hour of a day&#39;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s1">&#39;Drive count&#39;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s1">&#39;Histogram of drive statistics&#39;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>




<div class="output_png output_subarea ">
<img src="
"
>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="&#29983;&#25104;&#9121;&#25512;&#33616;&#20851;&#27880;&#9126;&#21644;&#9121;&#25105;&#20851;&#27880;&#30340;&#20027;&#39064;&#9126;&#23545;&#24212;&#20851;&#38190;&#35789;&#38598;&#30340;&#35789;&#20113;">&#29983;&#25104;&#9121;&#25512;&#33616;&#20851;&#27880;&#9126;&#21644;&#9121;&#25105;&#20851;&#27880;&#30340;&#20027;&#39064;&#9126;&#23545;&#24212;&#20851;&#38190;&#35789;&#38598;&#30340;&#35789;&#20113;<a class="anchor-link" href="#&#29983;&#25104;&#9121;&#25512;&#33616;&#20851;&#27880;&#9126;&#21644;&#9121;&#25105;&#20851;&#27880;&#30340;&#20027;&#39064;&#9126;&#23545;&#24212;&#20851;&#38190;&#35789;&#38598;&#30340;&#35789;&#20113;">&#182;</a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>即刻Web端首页右侧栏的推荐关注</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[17]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">recommended_topics</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get_recommended_topic</span><span class="p">()</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>加载至少200个推荐的主题</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[18]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">while</span> <span class="nb">len</span><span class="p">(</span><span class="n">recommended_topics</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">200</span><span class="p">:</span>
    <span class="n">recommended_topics</span><span class="o">.</span><span class="n">load_more</span><span class="p">()</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[19]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">recommended_topics</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[19]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>List(217 items)</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>给我推荐的前五个主题的关键词</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[20]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">for</span> <span class="n">topic</span> <span class="ow">in</span> <span class="n">recommended_topics</span><span class="p">[:</span><span class="mi">5</span><span class="p">]:</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">topic</span><span class="o">.</span><span class="n">keywords</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>


<div class="output_subarea output_stream output_stdout output_text">
<pre>单车 租赁 自行车 租赁 o2o ofo 骑行 mobike 共享单车
美团 人人网 饭否 bat 马化腾 马云 李彦宏 张一鸣 大众点评 o2o 龙岩
穿搭 搭配 服装 时尚
网易云音乐 网易 网易云 云音乐 营销
二次元 动漫 新番 动画 漫画 魔王 动漫头像
</pre>
</div>
</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>我自己关注的主题</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[21]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">my_subscribed_topics</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get_user_subscribed_topic</span><span class="p">(</span><span class="n">username</span><span class="o">=</span><span class="s1">&#39;WalleMax&#39;</span><span class="p">)</span>
<span class="n">my_subscribed_topics</span><span class="o">.</span><span class="n">load_all</span><span class="p">()</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[21]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>167</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>自己关注的最近五个主题的关键词</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[22]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">for</span> <span class="n">topic</span> <span class="ow">in</span> <span class="n">my_subscribed_topics</span><span class="p">[:</span><span class="mi">5</span><span class="p">]:</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">topic</span><span class="o">.</span><span class="n">keywords</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>


<div class="output_subarea output_stream output_stdout output_text">
<pre>想法 灵感 一个想法 杠精 思考
None
彩虹 合唱 金承志 张志超 神曲 音乐 作品 合唱 古典 搞怪
开箱 晒单 购物 评测
追踪 抓取 内测 邀请码
</pre>
</div>
</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>进行关键词计数</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[23]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="n">Counter</span>
<span class="n">recommended_keywords_counter</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">()</span>
<span class="n">subscribed_keywords_counter</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">()</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[24]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">for</span> <span class="n">topic</span> <span class="ow">in</span> <span class="n">recommended_topics</span><span class="p">:</span>
    <span class="n">recommended_keywords_counter</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">topic</span><span class="o">.</span><span class="n">keywords</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> <span class="k">if</span> <span class="n">topic</span><span class="o">.</span><span class="n">keywords</span> <span class="k">else</span> <span class="p">[])</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>“推荐关注”一共有1164个关键词</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[25]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="nb">len</span><span class="p">(</span><span class="n">recommended_keywords_counter</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[25]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>1164</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>“推荐关注”中出现频次最高的10个关键词及其对应频数</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[26]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">recommended_keywords_counter</span><span class="o">.</span><span class="n">most_common</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[26]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>[(&#39;搞笑&#39;, 14),
 (&#39;电影&#39;, 12),
 (&#39;明星&#39;, 10),
 (&#39;综艺&#39;, 9),
 (&#39;科技&#39;, 9),
 (&#39;娱乐&#39;, 8),
 (&#39;鹿晗&#39;, 7),
 (&#39;新闻&#39;, 6),
 (&#39;李易峰&#39;, 6),
 (&#39;日本&#39;, 6)]</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[27]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">for</span> <span class="n">topic</span> <span class="ow">in</span> <span class="n">my_subscribed_topics</span><span class="p">:</span>
    <span class="n">subscribed_keywords_counter</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">topic</span><span class="o">.</span><span class="n">keywords</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> <span class="k">if</span> <span class="n">topic</span><span class="o">.</span><span class="n">keywords</span> <span class="k">else</span> <span class="p">[])</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>“我关注的主题”一共有953个关键词</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[28]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="nb">len</span><span class="p">(</span><span class="n">subscribed_keywords_counter</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[28]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>953</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>“我关注的主题”中出现频次最高的10个关键词及其对应频数</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[29]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">subscribed_keywords_counter</span><span class="o">.</span><span class="n">most_common</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[29]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>[(&#39;阅读&#39;, 13),
 (&#39;搞笑&#39;, 12),
 (&#39;科普&#39;, 11),
 (&#39;热门&#39;, 11),
 (&#39;恋爱&#39;, 10),
 (&#39;好笑&#39;, 10),
 (&#39;新闻&#39;, 10),
 (&#39;科技&#39;, 9),
 (&#39;哄妹子&#39;, 9),
 (&#39;哄&#39;, 9)]</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>好奇，怎么会有 “哄妹子” 呢？ 🤔🤔🤔</p>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<hr>
<p>基于 <a href="https://github.com/amueller/word_cloud">Word Cloud</a> 生成关键词词云</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[30]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">PIL</span> <span class="k">import</span> <span class="n">Image</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
<span class="kn">from</span> <span class="nn">matplotlib.gridspec</span> <span class="k">import</span> <span class="n">GridSpec</span>
<span class="kn">from</span> <span class="nn">wordcloud</span> <span class="k">import</span> <span class="n">WordCloud</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[31]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="o">%</span><span class="k">matplotlib</span> inline
<span class="n">mask</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;jike.png&#39;</span><span class="p">))</span>
<span class="n">wc</span> <span class="o">=</span> <span class="n">WordCloud</span><span class="p">(</span><span class="n">background_color</span><span class="o">=</span><span class="s1">&#39;white&#39;</span><span class="p">,</span> <span class="n">max_words</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">mask</span><span class="o">=</span><span class="n">mask</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mi">800</span><span class="p">,</span>
               <span class="n">relative_scaling</span><span class="o">=</span><span class="mf">0.3</span><span class="p">,</span> <span class="n">random_state</span><span class="o">=</span><span class="mi">42</span><span class="p">,</span>
              <span class="n">font_path</span><span class="o">=</span><span class="s1">&#39;/System/Library/Fonts/PingFang.ttc&#39;</span><span class="p">)</span>

<span class="n">the_grid</span> <span class="o">=</span> <span class="n">GridSpec</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="n">wc</span><span class="o">.</span><span class="n">generate_from_frequencies</span><span class="p">(</span><span class="n">recommended_keywords_counter</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">the_grid</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">aspect</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s1">&#39;Recommendation World Cloud&#39;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">axis</span><span class="p">(</span><span class="s2">&quot;off&quot;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">imshow</span><span class="p">(</span><span class="n">wc</span><span class="p">,</span> <span class="n">interpolation</span><span class="o">=</span><span class="s2">&quot;bilinear&quot;</span><span class="p">)</span>

<span class="n">wc</span><span class="o">.</span><span class="n">generate_from_frequencies</span><span class="p">(</span><span class="n">subscribed_keywords_counter</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">the_grid</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">aspect</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s1">&#39;Subscription World Cloud&#39;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">axis</span><span class="p">(</span><span class="s2">&quot;off&quot;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">imshow</span><span class="p">(</span><span class="n">wc</span><span class="p">,</span> <span class="n">interpolation</span><span class="o">=</span><span class="s2">&quot;bilinear&quot;</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>




<div class="output_png output_subarea ">
<img src="
"
>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>我觉得吧，“推荐关注”词云里那么大的“鹿晗”，“李易峰”，“综艺”，“明星”和我的个人气质不大符合啊 🤔</p>
<p>即刻的推荐系统还有很大的进步空间</p>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="&#30001;&#37096;&#20998;&#25968;&#25454;&#20998;&#26512;&#21363;&#21451;&#30340;&#20998;&#24067;">&#30001;&#37096;&#20998;&#25968;&#25454;&#20998;&#26512;&#21363;&#21451;&#30340;&#20998;&#24067;<a class="anchor-link" href="#&#30001;&#37096;&#20998;&#25968;&#25454;&#20998;&#26512;&#21363;&#21451;&#30340;&#20998;&#24067;">&#182;</a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>获取 <a href="https://web.okjike.com/topic/5aaf50b9127e30001759c57e/user">我就想定个位</a> 主题下所有的广场动态</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[32]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">square</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get_topic_square</span><span class="p">(</span><span class="n">topic_id</span><span class="o">=</span><span class="s1">&#39;5aaf50b9127e30001759c57e&#39;</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[33]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="n">defaultdict</span>
<span class="n">city_counter</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">int</span><span class="p">)</span>
<span class="n">locations</span> <span class="o">=</span> <span class="p">[]</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>记录动态的定位城市和定位经纬度</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[34]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">while</span> <span class="n">square</span><span class="o">.</span><span class="n">load_more_key</span><span class="p">:</span>
    <span class="n">more</span> <span class="o">=</span> <span class="n">square</span><span class="o">.</span><span class="n">load_more</span><span class="p">()</span>
    <span class="k">for</span> <span class="n">post</span> <span class="ow">in</span> <span class="n">more</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">post</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="s1">&#39;ORIGINAL_POST&#39;</span> <span class="ow">and</span> <span class="n">post</span><span class="o">.</span><span class="n">poi</span><span class="p">:</span>
            <span class="n">city_counter</span><span class="p">[</span><span class="n">post</span><span class="o">.</span><span class="n">poi</span><span class="p">[</span><span class="s1">&#39;cityname&#39;</span><span class="p">]]</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">locations</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">post</span><span class="o">.</span><span class="n">poi</span><span class="p">[</span><span class="s1">&#39;location&#39;</span><span class="p">])</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>此主题广场下北京市的动态最多</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[35]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="nb">max</span><span class="p">(</span><span class="n">city_counter</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">i</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[35]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>(&#39;北京市&#39;, 34)</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>一共有406个经纬度信息</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[36]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="nb">len</span><span class="p">(</span><span class="n">locations</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[36]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>406</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[37]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">mpl_toolkits.basemap</span> <span class="k">import</span> <span class="n">Basemap</span>
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>墨绿色的标记点即为动态的发布地点，可见：</p>
<ul>
<li>“北上广”绿点密集</li>
<li>即友主要在中东部地区</li>
<li>台湾地区，韩国 🇰🇷和日本 🇯🇵都有即友哦</li>
</ul>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[38]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="o">%</span><span class="k">matplotlib</span> inline
<span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span><span class="mi">10</span><span class="p">))</span>
<span class="nb">map</span> <span class="o">=</span> <span class="n">Basemap</span><span class="p">(</span><span class="n">projection</span><span class="o">=</span><span class="s1">&#39;merc&#39;</span><span class="p">,</span> <span class="n">llcrnrlon</span><span class="o">=</span><span class="mi">70</span><span class="p">,</span> <span class="n">llcrnrlat</span><span class="o">=</span><span class="mi">15</span><span class="p">,</span>
        <span class="n">urcrnrlon</span><span class="o">=</span><span class="mi">140</span><span class="p">,</span> <span class="n">urcrnrlat</span><span class="o">=</span><span class="mi">55</span><span class="p">,</span> <span class="n">lat_0</span><span class="o">=</span><span class="mi">15</span><span class="p">,</span> <span class="n">lon_0</span><span class="o">=</span><span class="mi">95</span><span class="p">,</span> <span class="n">resolution</span><span class="o">=</span><span class="s1">&#39;h&#39;</span><span class="p">)</span>
<span class="nb">map</span><span class="o">.</span><span class="n">drawcoastlines</span><span class="p">(</span><span class="n">linewidth</span><span class="o">=</span><span class="mf">0.25</span><span class="p">)</span>
<span class="nb">map</span><span class="o">.</span><span class="n">drawcountries</span><span class="p">(</span><span class="n">linewidth</span><span class="o">=</span><span class="mf">0.25</span><span class="p">)</span>
<span class="nb">map</span><span class="o">.</span><span class="n">fillcontinents</span><span class="p">(</span><span class="n">color</span><span class="o">=</span><span class="s1">&#39;coral&#39;</span><span class="p">,</span><span class="n">lake_color</span><span class="o">=</span><span class="s1">&#39;aqua&#39;</span><span class="p">)</span>
<span class="nb">map</span><span class="o">.</span><span class="n">drawmapboundary</span><span class="p">(</span><span class="n">fill_color</span><span class="o">=</span><span class="s1">&#39;aqua&#39;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">loc</span> <span class="ow">in</span> <span class="n">locations</span><span class="p">:</span>
    <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="o">*</span><span class="n">loc</span><span class="p">)</span>
    <span class="nb">map</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="s1">&#39;go&#39;</span><span class="p">,</span> <span class="n">markersize</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s1">&#39; Jike POI Distribution &#39;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>




<div class="output_png output_subarea ">
<img src="
"
>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<hr>
<p><span style="float: left">Prev: <a href="./index.html">乘车指南 🚇</a></span>
<span style="float: right">Next: <a href="./objects.html">Jike Metro 🚇 中各个类的可用属性</a></span></p>

</div>
</div>
</div>
    </div>
  </div>
</body>

 


</html>
